﻿using System.Diagnostics;
using System.IO;
using HashFoo.MigratorFoo;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace HashFoo.MigratorFooTests
{
    
    
    /// <summary>
    ///This is a test class for MigrationConfigurationTest and is intended
    ///to contain all MigrationConfigurationTest Unit Tests
    ///</summary>
    [TestClass]
    public class MigrationConfigurationTest
    {

        [TestMethod]
        [Description("Tests that the configuration was deployed")]
        public void MockConfigExists()
        {
            var expectedPath = MockMigrationConfigPath;
            Debug.WriteLine(expectedPath);
            Assert.IsTrue(File.Exists(expectedPath));
        }

        /// <summary>
        ///A test for Load
        ///</summary>
        [TestMethod]
        public void LoadTest()
        {
            var configPath = MockMigrationConfigPath;
            var actual = MigrationConfiguration.Load(configPath);

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.DbConfigAssemblyPath.ToLowerInvariant().Contains("debug") ||
                          actual.DbConfigAssemblyPath.ToLowerInvariant().Contains("release"));
        }

        private static string MockMigrationConfigPath
        {
            get
            {
                return Util.BuildPathRelativeToExecuting("fixtures\\mock.migratorfoo");
            }
        }
    }
}
